﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:controls="clr-namespace:Framework.UI.Controls"
                    xmlns:params="clr-namespace:Elysium.Parameters;assembly=Elysium">
    <ResourceDictionary.MergedDictionaries>
        <controls:SharedResourceDictionary Source="/Framework.UI;component/Themes/WPF/Base/Converter.xaml"/>
        <controls:SharedResourceDictionary Source="/Framework.UI;component/Themes/WPF/Base/Brush.xaml"/>
        <controls:SharedResourceDictionary Source="/Framework.UI;component/Themes/WPF/Base/FocusVisualStyle.xaml"/>
        <controls:SharedResourceDictionary Source="/Framework.UI;component/Themes/ElysiumExtra/BorderFix.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style x:Key="TabItemHeaderStyle" TargetType="{x:Type ContentControl}" >
        <Setter Property="Background" Value="{StaticResource TransparentBrush}" />
        <Setter Property="BorderBrush" Value="{StaticResource LowlightBrush}" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="Foreground" Value="{StaticResource LowlightBrush}" />
        <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource Self},Path=(params:General.HeaderFontSize),Mode=OneWay}" />
        <Setter Property="FontStretch" Value="Medium" />
        <Setter Property="FontStyle" Value="Normal" />
        <Setter Property="FontWeight" Value="Normal" />
        <Setter Property="TextOptions.TextFormattingMode" Value="Display" />
        <Setter Property="TextOptions.TextRenderingMode" Value="ClearType" />
        <Setter Property="RenderOptions.ClearTypeHint" Value="Enabled" />
        <Setter Property="FocusVisualStyle" Value="{StaticResource {x:Static SystemParameters.FocusVisualStyleKey}}"/>
        <Setter Property="Focusable" Value="True" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Stretch" />
        <Setter Property="Padding" Value="{Binding RelativeSource={RelativeSource Self},Path=(params:General.BoldPadding),Mode=OneWay}" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ContentControl}">
                    <controls:BorderFix Background="{TemplateBinding Background}" 
                                   BorderBrush="{TemplateBinding BorderBrush}" 
                                   BorderThickness="{TemplateBinding BorderThickness}">
                        <Grid TextBlock.Foreground="{TemplateBinding Foreground}"
                              TextBlock.FontFamily="{TemplateBinding Control.FontFamily}" 
                              TextBlock.FontSize="{TemplateBinding FontSize}" 
                              TextBlock.FontStretch="{TemplateBinding FontStretch}" 
                              TextBlock.FontStyle="{TemplateBinding FontStyle}" 
                              TextBlock.FontWeight="{TemplateBinding FontWeight}" 
                              TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}" 
                              TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}" 
                              RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}" 
                              HorizontalAlignment="Stretch" 
                              VerticalAlignment="Stretch">
                            <Rectangle x:Name="Indicator" 
                                       StrokeThickness="0" 
                                       HorizontalAlignment="Stretch" 
                                       VerticalAlignment="Bottom" 
                                       Fill="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabItem}},Path=(params:TabControl.IndicatorBrush)}" 
                                       Height="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}},Path=(params:TabControl.IndicatorThickness)}"/>
                            <ContentPresenter Margin="{TemplateBinding Padding}" 
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}" 
                                              RecognizesAccessKey="True" />
                        </Grid>
                    </controls:BorderFix>
                    <ControlTemplate.Triggers>
                        <DataTrigger Value="{x:Static Dock.Bottom}" Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabItem}},Path=TabStripPlacement}">
                            <Setter TargetName="Indicator" Property="VerticalAlignment" Value="Top" />
                        </DataTrigger>
                        <DataTrigger Value="{x:Static Dock.Left}" Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabItem}},Path=TabStripPlacement}">
                            <Setter Property="FrameworkElement.LayoutTransform">
                                <Setter.Value>
                                    <RotateTransform RotateTransform.Angle="-90" />
                                </Setter.Value>
                            </Setter>
                            <Setter TargetName="Indicator" Property="VerticalAlignment" Value="Bottom" />
                        </DataTrigger>
                        <DataTrigger Value="{x:Static Dock.Right}" Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabItem}},Path=TabStripPlacement}">
                            <Setter Property="FrameworkElement.LayoutTransform">
                                <Setter.Value>
                                    <RotateTransform RotateTransform.Angle="90" />
                                </Setter.Value>
                            </Setter>
                            <Setter TargetName="Indicator" Property="VerticalAlignment" Value="Bottom" />
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <DataTrigger Value="{x:Static Dock.Left}" DataTrigger.Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabItem}},Path=TabStripPlacement}">
                <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" />
            </DataTrigger>
            <DataTrigger Value="{x:Static Dock.Right}" DataTrigger.Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabItem}},Path=TabStripPlacement}">
                <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" />
            </DataTrigger>
            <DataTrigger DataTrigger.Binding="{Binding RelativeSource={RelativeSource Self},Path=FontSize,Mode=OneWay,Converter={StaticResource IsGreaterThanConverter},ConverterParameter=18}">
                <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" />
            </DataTrigger>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}" />
            </Trigger>
            <DataTrigger DataTrigger.Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabItem}},Path=IsSelected}" Value="True">
                <Setter Property="BorderBrush" Value="{StaticResource AccentBrush}" />
                <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}" />
            </DataTrigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="BorderBrush" Value="{StaticResource DisabledBrush}" />
                <Setter Property="Foreground" Value="{StaticResource DisabledBrush}" />
            </Trigger>
        </Style.Triggers>
    </Style>
    <Style x:Key="{x:Type TabItem}" TargetType="{x:Type TabItem}" >
        <Setter Property="Background" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}},Path=Background,Mode=OneWay}" />
        <Setter Property="BorderBrush" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}},Path=BorderBrush,Mode=OneWay}" />
        <Setter Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}},Path=BorderThickness,Mode=OneWay}" />
        <Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}},Path=Foreground,Mode=OneWay}" />
        <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}},Path=FontSize,Mode=OneWay}" />
        <Setter Property="FontStretch" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}},Path=FontStretch,Mode=OneWay}" />
        <Setter Property="FontStyle" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}},Path=FontStyle,Mode=OneWay}" />
        <Setter Property="FontWeight" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}},Path=FontWeight,Mode=OneWay}" />
        <Setter Property="TextOptions.TextFormattingMode" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}},Path=(TextOptions.TextFormattingMode),Mode=OneWay}" />
        <Setter Property="TextOptions.TextRenderingMode" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}},Path=(TextOptions.TextRenderingMode),Mode=OneWay}" />
        <Setter Property="RenderOptions.ClearTypeHint" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}},Path=(RenderOptions.ClearTypeHint),Mode=OneWay}" />
        <Setter Property="FocusVisualStyle" Value="{StaticResource {x:Static SystemParameters.FocusVisualStyleKey}}"/>
        <Setter Property="Focusable" Value="True" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Stretch" />
        <Setter Property="Padding" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}},Path=Padding,Mode=OneWay}" />
        <Setter Property="params:TabItem.HeaderStyle" Value="{StaticResource TabItemHeaderStyle}" />
        <Setter Property="params:TabControl.IndicatorBrush" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}},Path=(params:TabControl.IndicatorBrush)}" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabItem}">
                    <ContentControl x:Name="ContentHost" ContentControl.Content="{TemplateBinding HeaderedContentControl.Header}" TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}" TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}" RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}" FrameworkElement.Style="{TemplateBinding params:TabItem.HeaderStyle}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <DataTrigger DataTrigger.Binding="{Binding RelativeSource={RelativeSource Self},Path=FontSize,Mode=OneWay,Converter={StaticResource IsGreaterThanConverter},ConverterParameter=18}">
                <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" />
            </DataTrigger>
            <Trigger Property="TabItem.IsSelected" Value="True">
                <Setter Property="params:TabControl.IndicatorBrush" Value="{StaticResource AccentBrush}" />
            </Trigger>
        </Style.Triggers>
    </Style>
    
</ResourceDictionary>